package com.wj.jiangan.controller;


import com.wj.jiangan.pojo.Productyear;
import com.wj.jiangan.service.IProductyearService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wj
 * @since 2019-11-05
 */
@RestController
@RequestMapping("/productyear")
public class ProductyearController {

    @Autowired
    public IProductyearService productyearService;

    /**
     * 根据产品id查询所有的年份信息
     * @param pid
     * @return
     */
    @GetMapping("{pid}")
    public List<Productyear> getProductYearByPid(@PathVariable Integer pid){
      return   productyearService.getProductYearByPid(  pid);
    }
    @GetMapping("/list/{pid}")
    public  Map<String, Object> getProductYearByPid2(@PathVariable Integer pid){
        Map<String, Object> result = new HashMap<>();
        result.put("code", 0);
        result.put("data", productyearService.getProductYearByPid(  pid));
        return    result;
    }



}


